<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>js简单的表格添加和删除</title>
		<script type="text/javascript" src="js/jquery-3.0.0.min.js" ></script>
		<script>
			function $c(tagname){
				return document.createElement(tagname);
			}
		$(document).ready(function(){
			$(document).bind("click",function(){
				var tab=$("#tab");
				var tr=$c("tr");
				tab.append(tr);
				var td1=$c("td");
				td1.innerHTML="1111";
				tr.appendChild(td1);
				var td2=$c("td");
				td2.innerHTML="2222";
				tr.appendChild(td2);
			});
			$("#deleterow").bind("click",function(){
				var tab=$("tab.tr:eq(0)");
				tab.remove();
			});
		});
		</script>
	</head>
	<body>
		<table border="1" id="tab">
			<tr>
				<td>1234</td>
				<td>5678</td>
			</tr>
		</table>
		<br />
		<button id="addrow">增行</button>
		<button id="deleterow">删行</button>
	</body>
</html>
